# -*- coding: utf-8 -*-
"""
Created on Tue Apr 21 14:47:14 2020

@author: Farman
"""


import pathlib
from   sklearn import svm
import joblib


data_file = r'D:\Pavia\Pavia\PaviaUniversity\Xy.joblib'

path = pathlib.Path(data_file).parent
X, y = joblib.load(data_file)

clf = svm.SVC(C = 1.0, 
              kernel = 'rbf', #‘linear’, ‘poly’, ‘rbf’, ‘sigmoid’, ‘precomputed’ or a callable
              degree = 3, #Degree of the polynomial kernel function (‘poly’). Ignored by all other kernels.
              gamma = 'scale', #{‘scale’, ‘auto’} or float, optional (default=’scale’)
                               #Kernel coefficient for ‘rbf’, ‘poly’ and ‘sigmoid’.
                               #if gamma='scale' (default) is passed then it uses 1 / (n_features * X.var()) as value of gamma,
                               #if ‘auto’, uses 1 / n_features.
              coef0 = 0.0, #Independent term in kernel function. It is only significant in ‘poly’ and ‘sigmoid’.
              shrinking = True, #boolean, optional (default=True)   Whether to use the shrinking heuristic.
              probability = False, #Whether to enable probability estimates. This must be enabled prior to calling fit, will slow down that method as it internally uses 5-fold cross-validation, and predict_proba may be inconsistent with predict. 
              tol = 0.001, 
              cache_size = 200, 
              class_weight = None, 
              verbose = False, 
              max_iter = -1, 
              decision_function_shape = 'ovr', 
              break_ties = False, 
              random_state = None)

clf.fit(X, y)

joblib.dump(clf, path / 'classifier.joblib')
